<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <link rel="stylesheet" type="text/css"
          href='<c:url context="${pageContext.request.contextPath}" value="/easyui/css/demo.css"/>'/>
    <link rel="stylesheet" type="text/css"
          href='<c:url context="${pageContext.request.contextPath}" value="/easyui/themes/default/easyui.css"/>'/>
    <link rel="stylesheet" type="text/css"
          href='<c:url context="${pageContext.request.contextPath}" value="/easyui/themes/icon.css"/>'/>
    <style type="text/css">
        .table th {
            font-weight: bold;
        }

        .table th,
        .table td {
            padding: 8px;
            line-height: 20px;
        }

        .table td {
            text-align: left;
        }

        .table-border {
            border-top: 1px solid #ddd;
        }

        .table-border th,
        .table-border td {
            border-bottom: 1px solid #ddd;
        }

        .table-bordered {
            border: 1px solid #ddd;
            border-collapse: separate;
            *border-collapse: collapse;
            border-left: 0;
        }

        .table-bordered th,
        .table-bordered td {
            border-left: 1px solid #ddd;
        }

        .table-border.table-bordered {
            border-bottom: 0;
        }

        .table-striped tbody> tr:nth-child(odd)> td,
        .table-striped tbody> tr:nth-child(odd)> th {
            background-color: #f9f9f9;
        }
    </style>

    <script type="text/javascript"
            src='<c:url context="${pageContext.request.contextPath}" value="/easyui/jquery.min.js"/>'></script>
    <script type="text/javascript"
            src='<c:url context="${pageContext.request.contextPath}" value="/easyui/jquery.easyui.min.js"/>'></script>
    <script type="text/javascript"
            src='<c:url context="${pageContext.request.contextPath}" value="/easyui/js/validateExtends.js"/>'></script>
    <script type="text/javascript" src='<c:url context="${pageContext.request.contextPath}" value="/easyui/js/easyui-lang-zh_CN.js"/>'></script>
    <script type="text/javascript">
        $(function() {

            //修改密码窗口
            $("#passwordDialog").dialog({
                title: "修改密码",
                width: 500,
                height: 300,
                iconCls: "icon-add",
                modal: true,
                collapsible: false,
                minimizable: false,
                maximizable: false,
                draggable: true,
                closed: true,
                buttons: [{
                    text: '提交',
                    iconCls: 'icon-user_add',
                    handler: function() {
                        var validate = $("#editPassword").form("validate");
                        if(!validate) {
                            $.messager.alert("消息提醒", "请检查你输入的数据!", "warning");
                            return;
                        } else {
                            $.ajax({
                                type: "post",
                                url: "SystemServlet?method=EditPasswod&t=" + new Date().getTime(),
                                data: $("#editPassword").serialize(),
                                success: function(msg) {
                                    if(msg == "success") {
                                        $.messager.alert("消息提醒", "修改成功，将重新登录", "info")
                                        setTimeout(function() {
                                            top.location.href = "SystemServlet?method=LoginOut";
                                        }, 1000);
                                    }
                                }
                            });
                        }
                    }
                }, {
                    text: '重置',
                    iconCls: 'icon-reload',
                    handler: function() {
                        //清空表单
                        $("#old_password").textbox('setValue', "");
                        $("#new_password").textbox('setValue', "");
                        $("#re_password").textbox('setValue', "");
                    }
                }],
            })

            //设置编辑学生窗口
            $("#editDialog").dialog({
                title: "修改密码",
                width: 500,
                height: 400,
                fit: true,
                modal: false,
                noheader: true,
                collapsible: false,
                minimizable: false,
                maximizable: false,
                draggable: true,
                closed: false,
                toolbar: [{
                    text: '重置',
                    plain: true,
                    iconCls: 'icon-reload',
                    handler: function() {
                        //清空表单
                        $("#customerName").textbox('setValue', "");
                        $("#gender").textbox('setValue', "");
                        $("#idCard").textbox('setValue', "");
                        $("#phone").textbox('setValue', "");
                        $("#aginPhone").textbox('setValue', "");
                        $("#password").textbox('setValue', "");
                        $("#cardType").textbox('setValue', "");
                    }
                }, '-', {
                    text: '修改密码',
                    plain: true,
                    iconCls: 'icon-password',
                    handler: function() {
                        $("#passwordDialog").dialog("open");
                    }
                }],

            });

            //修改
            $("#systemTable a").each(function() {
                $(this).click(function() {
                    var input = $(this).parents("tr").find("input");
                    var inputName = $(input).attr("name");
                    var name = "";
                    var value = "";
                    if(inputName == "forbidTeacher" || inputName == "forbidStudent") {
                        name = inputName;
                        if($(input).attr("checked")) {
                            value = 1;
                        } else {
                            value = 0;
                        }
                    } else {
                        var name = $(input).attr("textboxname");
                        var value = $(input).textbox("getValue");
                    }

                    //保存
                    var data = {
                        'name': name,
                        'value': value
                    };
                    $.ajax({
                        type: "post",
                        url: "SystemServlet?method=EditSystemInfo&t=" + new Date().getTime(),
                        data: data,
                        success: function(msg) {
                            if(msg == "success") {
                                $.messager.alert("消息提醒", "保存成功", "info");
                            }
                        }
                    });
                });
            });
            // ====================================================
            $("#submitBtn").click(function () {
               // var data = $("#systemTable").serialize();
                var customerName=$("#customerName").val();
                var gender=$("#gender").val();
                var idCard=$("#idCard").val();
                var phone=$("#phone").val();
                var aginPhone=$("#aginPhone").val();
                var password=$("#password").val();
                var cardType=$("#cardType").val();


               var data={customerName:customerName,gender:gender,idCard:idCard,password:password, phone: phone,cardType:cardType};
                $.ajax({
                    type: "post",
                    url: "phoneAdd",
                    data: data,
                    dataType: "json", //返回数据类型
                    success: function(msg) {
                        if(msg.status==500) {
                            $.messager.alert("消息提醒", msg.msg, "warning");

                        }else if (msg.status == 200) {
                            $.messager.alert("消息提醒", msg.msg, "warning");

                        }
                    }
                });
            })
            function submitForm(){
                var data = $("#systemTable").serialize();
                $.ajax({
                    type: "post",
                    url: "/phoneAdd",
                    data: data,
                    dataType: "json", //返回数据类型
                    success: function(msg) {
                        if(msg.status==500) {
                            $.messager.alert("消息提醒", msg.msg, "warning");

                        }else if (msg.status == 200) {
                            $.messager.alert("消息提醒", msg.msg, "warning");
                            window.location.href = "/phoneAdd";
                        }
                    }
                });
            }
            //==================================================================
        })


    </script>
</head>

<body>

<div id="editDialog" style="padding: 20px;">
    <div style="width: 650px">
        <table id="systemTable" class="table table-border table-bordered table-striped" style="width: 460px" cellpadding="8">
            <tr>
                <td width="50">开户姓名:</td>
                <td width="350">
                    <input id="customerName"  class="easyui-textbox" style="width: 300px; height: 30px;" type="text" name="customerName" />
                </td>
            </tr>
            <tr>
                <td width="50">性别:</td>
                <td width="350">
                    <input id="gender"  class="easyui-textbox" style="width: 300px; height: 30px;" type="text" name="gender" />
                </td>
            </tr>
            <tr>
                <td width="200">身份证号:</td>
                <td width="350">
                    <input id="idCard"  class="easyui-textbox" style="width: 300px; height: 30px;" type="text" name="idCard" />
                </td>
            </tr>
            <tr>
                <td width="200">手机号:</td>
                <td width="350">
                    <input id="phone"  class="easyui-textbox" style="width: 300px; height: 30px;" type="text" name="phone" />
                </td>
            </tr>
            <tr>
                <td width="200">确认号码:</td>
                <td width="350">
                    <input id="aginPhone"  class="easyui-textbox" style="width: 300px; height: 30px;" type="text" name="aginPhone" />
                </td>
            </tr>
            <tr>
                <td width="200">手机密码:</td>
                <td width="350">
                    <input id="password"  class="easyui-textbox" value="123456" style="width: 300px; height: 30px;" type="password" name="password" />
                </td>
            </tr>
            <tr>
                <td width="200">开户类型:</td>
                <td width="350">
                    <input id="cardType"  class="easyui-textbox" style="width: 300px; height: 30px;" type="text" name="cardType" />
                </td>
            </tr>
            <tr>
                <input id="submitBtn" type="submit" value="开户"  />
            </tr>

        </table>
    </div>
</div>

</body>

</html>